package com.eascs.ant.user.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;

import com.eascs.web.interceptor.AnnotationProcessorAdapter;
import com.eascs.web.sso.NoPermissionException;
import com.eascs.web.sso.UserHolder;

@Component
public class SuperAdministratorAnnotationProcessor extends AnnotationProcessorAdapter<SuperAdministrator> {

	@Override
	public void preHandle(SuperAdministrator annotation, HandlerMethod handlerMethod) {
		if (!UserHolder.getUser().isSuperAdministrator()) {
			throw new NoPermissionException();
		}
		super.preHandle(annotation, handlerMethod);
	}

	@Override
	public Class<SuperAdministrator> getAnnotation() {
		return SuperAdministrator.class;
	}

}
